home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / Source / MultiSession 1.04 Source / Core 27⁄June⁄1993 / Alert.c next >
Encoding:
C/C++ Source or Header  |  1993-06-04  |  2.6 KB  |  119 lines  |  [TEXT/KAHL]

  1. /* Alert.c */
  2.  
  3. #include "Alert.h"
  4. #include "CModalDialog.h"
  5. #include "CSimpleButton.h"
  6. #include "Memory.h"
  7. #include "CImagePane.h"
  8. #include "CStaticText.h"
  9. #include "StringUtils.h"
  10.  
  11.  
  12. #define AlertWindowLocID (0x00810001)
  13. #define KillButtonLocID (0x00810003)
  14. #define TextLocID (0x00810004)
  15. #define PictLocID (0x00820000) /* add PICT ID to find local index */
  16.  
  17. #define KillButtonNameID (0x00810001)
  18.  
  19. #define ErrorPictID (136)
  20.  
  21.  
  22. /********************************************************************************/
  23.  
  24. struct    CAlertDialog    :    CModalDialog
  25.     {
  26.         void        DoEventLoop(void);
  27.     };
  28.  
  29.  
  30. void        CAlertDialog::DoEventLoop(void)
  31.     {
  32.         FlushEvents(everyEvent,0);
  33.         inherited::DoEventLoop();
  34.     }
  35.  
  36.  
  37. /********************************************************************************/
  38.  
  39. struct    CKillButton    :    CSimpleButton
  40.     {
  41.         void            IKillButton(CModalDialog* TheDialog);
  42.         MyBoolean    DoThang(void);
  43.     };
  44.  
  45.  
  46. void        CKillButton::IKillButton(CModalDialog* TheDialog)
  47.     {
  48.         LongPoint    Start;
  49.         LongPoint    Extent;
  50.  
  51.         GetRect(KillButtonLocID,&Start,&Extent);
  52.         ISimpleButton(Start,Extent,GetCString(KillButtonNameID),0x0d,0,TheDialog,TheDialog);
  53.     }
  54.  
  55.  
  56. MyBoolean    CKillButton::DoThang(void)
  57.     {
  58.         delete Window;
  59.         return True;
  60.     }
  61.  
  62.  
  63. /********************************************************************************/
  64.  
  65.  
  66. void        AlertError(ulong MessageID, Handle ExtraText)
  67.     {
  68.         CModalDialog*        AlertWindow;
  69.         CKillButton*        Button;
  70.         CImagePane*            Icon;
  71.         CStaticText*        StaticText;
  72.         LongPoint                Start;
  73.         LongPoint                Extent;
  74.         Handle                    MessageText;
  75.         Handle                    AccumulatedText;
  76.  
  77.  
  78.         StackSizeTest();
  79.         if (MessageID != 0)
  80.             {
  81.                 MessageText = GetCString(MessageID);
  82.             }
  83.          else
  84.             {
  85.                 MessageText = AllocHandle(0);
  86.             }
  87.         if (ExtraText == NIL)
  88.             {
  89.                 ExtraText = AllocHandle(0);
  90.             }
  91.  
  92.         BeginStringOperation();
  93.         RegisterString(MessageText);
  94.         RegisterString(ExtraText);
  95.         AccumulatedText = ReplaceStr(MessageText,CString("_"),ExtraText);
  96.         EndStringOperation(AccumulatedText);
  97.  
  98.         GetRect(AlertWindowLocID,&Start,&Extent);
  99.         Start = AlertCenterRect(Extent,LongPointOf(screenBits.bounds.right
  100.             - screenBits.bounds.left,screenBits.bounds.bottom - screenBits.bounds.top));
  101.         AlertWindow = new CAlertDialog;
  102.         AlertWindow->IModalDialog(Start,Extent,DontAllowMenus);
  103.  
  104.         GetRect(TextLocID,&Start,&Extent);
  105.         StaticText = new CStaticText;
  106.         StaticText->IStaticText(Start,Extent,AccumulatedText,0,12,AlertWindow,
  107.             AlertWindow,JustifyLeft);
  108.  
  109.         GetRect(PictLocID + ErrorPictID,&Start,&Extent);
  110.         Icon = new CImagePane;
  111.         Icon->IImagePane(Start,Extent,AlertWindow,AlertWindow,ErrorPictID);
  112.  
  113.         Button = new CKillButton;
  114.         Button->IKillButton(AlertWindow);
  115.  
  116.         SysBeep(20);
  117.         AlertWindow->DoEventLoop();
  118.     }
  119.